<?
if(!ANTIHACK) die("ANTIHACK...");
include_once(INCLUDES."buildlink.php");
include_once(INCLUDES."paging.php");
include_once(INCLUDES."split_unicode.php");
$sel=query("select * from quangcao where position=2 and is_active=1 order by sort asc");
$i=0;
$data=array();
while($fsel=fetch($sel))
{
	$fsel['count']=$i;
	$getqc=query("select * from link_quangcao where parent=".$fsel['id']);
	$img=array();
	$url=array();
	while($fgetqc=fetch($getqc))
	{
		$img[]=$fgetqc['img'];
		$url[]=baselink.'/clickads.php?id='.$fgetqc['id'].'&url='.$fgetqc['url'];
	}
	$fsel[img]=$img;
	$fsel[url]=$url;
	$data[]=$fsel;
	$i++;
}

$smarty->assign("qc_data",$data);
$sel=query("SELECT count( id ) AS count, idpost FROM `logs` GROUP BY idpost ORDER BY `count` DESC limit 4");
$dataPost=array();
while($fsel=fetch($sel))
{
	$p=query("select * from post where id=".$fsel['idpost']);
	$fp=fetch($p);
	$fp["link"]=buildlink("post",$fp,"",1);
	$dataPost[]=$fp;
}
$smarty->assign("dataPost",$dataPost);
$datard=array();

	$p=query("select * from post ORDER BY RAND() limit 4");
	while($fp=fetch($p))
	{
		$fp["link"]=buildlink("post",$fp,"",1);
		$datard[]=$fp;
	}
$smarty->assign("datard",$datard);

$sel=query("select * from quangcao where position=6 and is_active=1 order by sort asc");
$i=0;
$data=array();
while($fsel=fetch($sel))
{
	$fsel['count']=$i;
	$getqc=query("select * from link_quangcao where parent=".$fsel['id']);
	while($fgetqc=fetch($getqc))
	{
		$code=explode("?v=",$fgetqc['img']);
		$code=$code[1];
		$code=explode("&",$code);
		$code=$code[0];
		$c[]=$code;
		$t[]=$fgetqc['url'];
	}
		$fsel["code"]=$c;
		$fsel["title"]=$t;
	$data[]=$fsel;
	$i++;
}
$smarty->assign("qc_video",$data);
$smarty->display("rightframe.htm");
?>